﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Xml.XmlDocument>" %>
<div class="hidden">
<div id="breakglass" class="modal">
	<p>This document contains sensitive information.</p>
	<p>Click the break glass button below to view.</p>
	<p>This action will be recorded.</p>
	<button id="btnBreakglass" documentid="">Break glass</button>
</div>
</div>
<%= Documents.Common.Helpers.XmlHelper.TransformXML(Model,Server.MapPath(@"~\Transforms\Documents.xslt")) %>

<script type="text/javascript">
    $('#documents').fixedHeaderTable({ footer: false, cloneHeadToFoot: true, fixedColumn: false });
    $("#documents tbody tr").click(function() {
        $("#state #documentOrigin").val("documentlist");
        $('#documentmetadata').unblock();

        if (!$(this).hasClass("selected")) {
            if ($(this).attr("sensitive") == "false") {
                $('#contentviewer').unblock();
                $.unblockUI();
            };
        };


        if (!$(this).hasClass("selected")) {
            $("#documents tbody tr").removeClass("selected");
            $(this).addClass("selected");
            DocumentListItemClick($(this));
        };
    });
    
    function SelectDocumentByDocumentID(documentid) {
        var documentlistitem = ($("#documents tbody tr.document[documentid='" + documentid + "']"));
        $("#documents tbody tr").removeClass("selected");
        $(documentlistitem).addClass("selected");
        DocumentListItemClick(documentlistitem);
    }

    function DocumentListItemClick(item) {
        var eventArgs = { sensitive: $(item).attr("sensitive"), documentid: $(item).attr("documentid")};
        eventHub.RaiseEvent(DocumentEvents.OnDocumentSelect, eventArgs);
    }

</script>
